<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <link rel="icon" href="/public/commonHeader.png">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>常用js工具库</title>
  </head>
  <body>
  
  </body>
  <script>
        // 12345678910      ===>  12, 345, 678, 910


        const strFunction = ()=>{
          let num = '12345678910'
          let b =num.split('').reverse() // ["0", "1", "9", "8", "7", "6", "5", "4", "3", "2", "1"]
          for (let i = 0; i < b.length; i++) {
              if((i+1)%4==0){
                  b.splice(i,0,',')
              }
          }
          b.reverse() //["1", "2", ",", "3", "4", "5", ",", "6", "7", "8"",", "9", "1", "0"]
          let str = ''
          b.forEach(item => str+=item);
          console.log(str);  //12,345,678,910
          }

          strFunction()
  </script>
</html>
